import request from '@/utils/request';
import { IApprovalVO, IApprovalDTO, IApprovalQuery } from '.';

//待我审批列表
export function fetchList(query?: IPaginationQuery & IApprovalQuery): IPaginationResWrapper<IApprovalVO> {
	return request({
		url: '/oa/process/needTodo',
		method: 'get',
		params: query,
	});
}

export function getMyLaunch(query?: IPaginationQuery & IApprovalQuery): IPaginationResWrapper<IApprovalVO> {
	return request({
		url: '/oa/process/queryMyLaunch',
		method: 'get',
		params: query,
	});
}

export function queryMyReceiveTask(query?: IPaginationQuery & IApprovalQuery): IPaginationResWrapper<IApprovalVO> {
	return request({
		url: '/oa/process/queryMyReceiveTask',
		method: 'get',
		params: query,
	});
}

export function approve(obj?: IApprovalDTO): IResWrapper<IApprovalVO> {
	return request({
		url: '/oa/process/approve',
		method: 'post',
		data: obj,
	});
}

export function getObj(id?: string): IResWrapper<IApprovalVO> {
	return request({
		url: '/oa/askForLeave/' + id,
		method: 'get',
	});
}

export function delObjs(ids?: string[]) {
	return request({
		url: '/oa/askForLeave',
		method: 'delete',
		data: ids,
	});
}

export function putObj(obj?: IApprovalDTO): IResWrapper<IApprovalVO> {
	return request({
		url: '/oa/askForLeave',
		method: 'put',
		data: obj,
	});
}
